package com.heisenhub.logs.controller;


import com.heisenhub.common.db.controller.AbstractController;
import com.heisenhub.common.oauth.annotation.ApiResourceOpen;
import com.heisenhub.logs.common.dto.LogsRecordsDto;
import com.heisenhub.logs.common.enums.LogsEnums;
import com.heisenhub.logs.entity.LogsRecords;
import com.heisenhub.logs.query.LogsQuery;
import com.heisenhub.logs.service.ILogsRecordsService;
import com.heisnenhub.common.module.enmus.BusinessTypeEnums;
import com.heisnenhub.common.module.inter.BusinessTypeEnumsInter;
import com.heisnenhub.common.module.utils.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 日志记录表 前端控制器
 * </p>
 *
 * @author sen
 * @since 2024-04-24
 */
@RestController
@RequestMapping("/log")
public class LogsRecordsController extends AbstractController<LogsRecords, LogsRecordsDto, LogsQuery, ILogsRecordsService> {



    @ApiResourceOpen
    @PostMapping(path = "/save",name="添加日志")
    public Api savelogs(@RequestBody @Validated LogsRecordsDto addDto) {
        LogsRecords logsRecords = formConvert(addDto);
        return  Api.of(service.save(logsRecords)).build() ;
      //  return super.save(addDto);
    }

    @Override
    public BusinessTypeEnumsInter getBusinessTypeEnums() {
        return LogsEnums.LOGS;
    }
}
